package models

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

type Goods struct {
	Id     int     `json:"id"`
	Name   string  `json:"name"`
	Price  float64 `json:"price"`
	Author string  `json:"author"`
}

var DB *gorm.DB

func init() {
	dsn := "root:root@tcp(127.0.0.1:3306)/day13"
	var err error
	DB, err = gorm.Open(mysql.Open(dsn))
	if err != nil {
		panic("数据库连接失败")
	}
	DB.AutoMigrate(&Goods{})
}
